#include<iostream>
#include <string>
#include <vector>
#include <algorithm>
#include<stdio.h>
using namespace std;
class Solution {
public:
    vector<string> letterCombinations(string digits) {
        string a[] = { "" ,"","abc","def","ghi","jkl","mno","pqrs","tuv","wxyz" };
        int t[2000], d[2000], n = digits.length();
        vector<string> ans;
        if (n == 0)return ans;
        for (int i = 0; i < n; i++)
        {
            d[i] = digits[i] - '0';
            t[i] = 0;
        }
        t[n] = 0;
        while (t[n] == 0)
        {
            string temp = "";
            int i;
            for (i = 0; i < n; i++)
            {
                temp += a[d[i]][t[i]];
            }
            ans.push_back(temp);
            t[0]++;
            i = 0;
            while (i < n && t[i] >= a[d[i]].length())
            {
                t[i + 1] += t[i] / a[d[i]].length();
                t[i] %= a[d[i]].length();
                i++;
                
            }
        }
        return ans;
    }
};
int main()
{
    Solution sol;
    sol.letterCombinations("23456");
}